//
//  MoreHeadView.m
//  Yarhoo
//
//  Created by 杨春至 on 2018/5/29.
//  Copyright © 2018年 Yarhoo. All rights reserved.
//

#import "MoreHeadView.h"


static CGFloat AVATOR_HEIGHT = 60.0;

@interface MoreHeadView()

@property (nonatomic,strong) UIImageView *avator;

@property (nonatomic,strong) UILabel *phoneLb;

@property (nonatomic,strong) UIProgressView *progressView;

@property (nonatomic,strong) UILabel *contentLb;

@property (nonatomic,strong) UIButton *dredgeBtn;

@end

@implementation MoreHeadView

- (instancetype)init{
    if ([super init]) {
        [self configUI];
    }
    return self;
}
- (void)configUI{
    self.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.avator];
    [self addSubview:self.phoneLb];
    [self addSubview:self.progressView];
    [self addSubview:self.contentLb];
    [self addSubview:self.dredgeBtn];
//todo
    _avator.backgroundColor = [UIColor qmui_randomColor];
    _phoneLb.text = @"18516773736";
    _progressView.progress = 0.25;
    _contentLb.text = @"容量 25G/100G 25%";
    
}
- (void)layoutSubviews{
    [super layoutSubviews];
    CGFloat gap = 15;
    [_avator mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.top.equalTo(@(gap));
        make.size.mas_equalTo(CGSizeMake(60, 60));
    }];
    [_phoneLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(_avator);
        make.top.equalTo(_avator.mas_bottom).offset(gap);
        make.left.right.equalTo(self);
        make.height.equalTo(@(gap));
    }];
    [_progressView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(_avator);
        make.top.equalTo(_phoneLb.mas_bottom).offset(gap);
        make.width.equalTo(self).multipliedBy(0.5);
        make.height.equalTo(@(gap));
    }];
    [_contentLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(_avator);
        make.top.equalTo(_progressView.mas_bottom).offset(gap);
        make.width.height.equalTo(_phoneLb);
    }];
    [_dredgeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(_avator);
        make.top.equalTo(_contentLb.mas_bottom).offset(gap);
        make.size.mas_equalTo(CGSizeMake(80, 30));
    }];
}
- (UIImageView *)avator{
    if (!_avator) {
        _avator = [UIImageView new];
        _avator.clipsToBounds = YES;
        _avator.layer.cornerRadius = AVATOR_HEIGHT*0.5;
    }
    return _avator;
}
- (UILabel *)phoneLb{
    if (!_phoneLb) {
        _phoneLb = [UILabel new];
        _phoneLb.textAlignment = NSTextAlignmentCenter;
        _phoneLb.font = [UIFont systemFontOfSize:14];
    }
    return _phoneLb;
}
- (UIProgressView *)progressView{
    if (!_progressView) {
        _progressView = [UIProgressView new];
        _progressView.progressTintColor = KcolorBlue;
        _progressView.trackTintColor = [UIColor qmui_colorWithHexString:@"#E3E8EF"];
        _progressView.layer.borderColor = [UIColor whiteColor].CGColor;
        _progressView.layer.borderWidth = 1;
        _progressView.clipsToBounds = YES;
        _progressView.layer.cornerRadius = 1;
    }
    return _progressView;
}
- (UILabel *)contentLb{
    if (!_contentLb) {
        _contentLb = [UILabel new];
        _contentLb.textAlignment = NSTextAlignmentCenter;
        _contentLb.font = [UIFont systemFontOfSize:11];
        _contentLb.textColor = [UIColor qmui_colorWithHexString:@"#112D55"];
    }
    return _contentLb;
}
- (UIButton *)dredgeBtn{
    if (!_dredgeBtn) {
        _dredgeBtn = [UIButton new];
        [_dredgeBtn setTitle:@"开通VIP" forState:UIControlStateNormal];
        [_dredgeBtn setTitleColor:[UIColor qmui_colorWithHexString:@"#112D55"] forState:UIControlStateNormal];
        _dredgeBtn.clipsToBounds = YES;
        _dredgeBtn.layer.cornerRadius = 3;
        _dredgeBtn.layer.borderColor = [UIColor blackColor].CGColor;
        _dredgeBtn.layer.borderWidth = 1;
        _dredgeBtn.backgroundColor = [UIColor qmui_colorWithHexString:@"#FFCF78"];
        _dredgeBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    }
    return _dredgeBtn;
}
@end
